<?php
session_start();//开启session
?>
<!DOCTYPE html>
<html>
    <head>
        <title>修改用户角色关联关系</title>
        <meta charset="utf-8" />
        <link type="text/css" rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" />
        <script type="text/javascript" src="../bootstrap/js/jquery-1.9.1.min.js"></script>
        <script type="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>
        <style type="text/css">
        .form-group{line-height: 35px;}
        </style>
        <script type="text/javascript">
        $(function(){
            //加载所有的用户 当前角色与所有用户的关联关系
            $.getJSON("../index.php?c=Permision&a=loadAllUserRole&rid=<?php echo $_GET["rid"];?>",function(data){
                for(var i=0;i<data.length;i++){
                    $("#userRoleData").append("<input type='checkbox' name='uids[]' value='"+data[i].uid+"' "+(data[i].isChecked==1?"checked":"")+" />&nbsp;"+data[i].userName+"<br/>");
                }
            });
            $("#btn-editUserRole").click(function(){
                var param = $("#editUserRoleForm").serialize();
                $.getJSON("../index.php",param,function(data){
                    if(data.result == "ok"){
                        alert("用户角色关联关系修改成功！");
                    }
                });
            });
        });

        </script>
    </head>
    <body>
        <form id="editUserRoleForm">
            <input type="hidden" name="rid" value="<?php echo $_GET["rid"];?>" />
            <input type="hidden" name="c" value="Permision" />
            <input type="hidden" name="a" value="editUserRole" />
            <div id="userRoleData"></div>
            <button type="button" class="btn btn-primary" id="btn-editUserRole">确认</button>
        </form>
    </body>
</html>